<?
	session_start();
	include("../model/database.php");
	include("../model/xl_nguoi_dung.php");
	
    	
	
	if( isset($_POST['Email'])&& isset($_POST['Password'])){
		$email = $_REQUEST['Email'];
		$pass = $_REQUEST['Password'];
		
		$email = stripslashes($email);
		$pass = stripslashes($pass);
		
		$email = mysql_real_escape_string($email);
		$pass = mysql_real_escape_string($pass);
		
		$success = false;
		$active = false;
		$error = "";
		$xl_nguoi_dung = new xl_nguoi_dung();
		$nguoi_dung = $xl_nguoi_dung->kiemTraDangNhap($email,$pass);
		$n = count($nguoi_dung);
		if($n>0){
			$success = true;
			$row = $nguoi_dung[0];
			if($row['KickHoat']== '1'){
				$active = true;
				$_SESSION['usid'] = $row['MaNguoiDung'];
				$_SESSION['email'] = $row['Email'];
				$_SESSION['ava'] = $row['HinhAnhDaiDien'];
				$_SESSION['fullname'] = $row['TenHienThi'];
				$_SESSION['oauth'] = $row['oauth_provider'];
				
			}
		}
		
		$data = array("success"=>$success,"session"=>$_SESSION,"active"=>$active);
		echo json_encode($data);
	}
?>